<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>经验值</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/style.css" />
	<link rel="stylesheet" type="text/css" href="../../css/yzl.css" />
	<link rel="stylesheet" type="text/css" href="../../css/vant.css" />

	<!-- <link rel="stylesheet" href="../../css/BarlowCondensed-Bold.woff.ttf" /> -->
	<!-- <link rel="stylesheet" href="../../css/sqc.css"> -->
	<style>
	*{
		margin: 0;
		padding: 0;
	}
	input{
		outline:none;
    border: none;
    resize: none;
	}
  textarea{
             width: 100%;
             border: none;
             resize: none;
             cursor: pointer;
         }
  .news_image img{
    width:28%;
    margin:2%;
  }
  .news_footer img{
    vertical-align: middle;
  }
  .news_footer{
    text-align: center;
    position: fixed;
    bottom: 20px;
    width: 100%;
  }
  .news_footer div{
    display: inline-block;
    color: #ffffff;
    vertical-align: middle;
    background-color: #F95656;
    width: 74%;
    padding: 6px;
    text-align: center;
    border-radius: 22px;

  }

	</style>
</head>

<body style="background:#ffffff">
  <div id="blank" class="header" v-cloak>
    <div v-back.tapmode class="back"></div>
    <div class="title">编辑状态</div>
  </div>
  <div id="app" v-cloak class="container" style="padding-top:60px;">
    <div class="news_container" style="width:80%;margin:0 auto">
    <div class="news_title" >
      <input v-model="title" placeholder="有趣的标题会有更多的赞哦~"  style="padding:8px 0px">
    </div>
    <div class="news_content" style="margin-top:30px">
      <textarea v-model="message" placeholder="添加正文" style="text-align:left;border:none">

      </textarea>
    </div>
    <div class="news_image" style="margin-top:20px;">
      <img v-for="(content, index) in fileList" :src="content"  width="30%">
      <img src="../../image/add_pricture.png" v-myclick="show_pick">
    </div>

	</div>
  <div class="news_footer">
    <img style="width:30px" v-src="'../../image/caogao.png'" v-myclick="[0,submit]">
    <div style="margin-left:5px;padding:10px" v-myclick="[1,submit]">发布状态</div>
  </div>

	</div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script src="../../script/components.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript" src="../../script/vant.min.js"></script>

<script>
	var vm,
		wx,
		aliTradePlus,
		qq,
		talkingData;
	apiready = function () {
		setBSImg();
		new Vue({
			el: '#blank'
		})
		wx = api.require('wx');
		console.log(JSON.stringify(api.pageParam))

		// setBSImg();
		initApp();
		api.parseTapmode();
	};

	function initApp() {
		// var isBigImg = Vue.BSImg == 'big';
		vm = new Vue({
			el: '#app',
			data: {
				modal:true,
				list:true,
				active_index:1,
        title:api.pageParam.infos.title,
        message:api.pageParam.infos.content,
        fileList: api.pageParam.infos.image_info,
				upload_arr:[]
			},
      mounted: function () {
			},
			methods: {
				showmodal:function(){
					this.modal = !this.modal
				},
				show_pick:function(){
					var selectPic = api.require('selectPic');
					var param = {
							maxNum : 9 //用户选择的最多图片张数
					};
					selectPic.showPics(param, function(ret, err) {
						for (var i = 0; i < ret.data.length; i++) {
							vm.upload_qiniu(ret.data[i],i);
						}
							// vm.fileList.push(ret.data);
					});
				},
				submit:function(status){
					showProgress();
					// var filearr = this.fileList;
					var data = {
							member_id: getPrefs('member_id'),
							title: vm.title,
							content: vm.message,
							flag:status,
							image_array:JSON.stringify(this.fileList)
					};
					if(status==1){
						data['dynamic_id'] = api.pageParam.infos.id
					}
					var callback = function (ret) {
						api.toast({
								msg: ret.message,
								duration: 2000,
								location: 'middle'
						});

						api.sendEvent({
						    name: 'new_load',
						});


						closeWin();

					};
					pinet.post(APIURL+'/app/dynamic/publishDynamic', data, callback);

				},
				upload_qiniu(file,index){
					// console.log(file)
							var obj = api.require('qiniuUpfile');
							var savename = new Date().getTime() +index+ '.png';
							obj.upfile({
								file: file,
								name: savename
							}, function (ret, err) {
								// console.log(JSON.stringify(ret))
								if (ret.status) {
									if (ret.oper == "complete") {
										vm.fileList.push(qiniuhost + ret.info.key);
										// return qiniuhost + ret.info.key;
										// console.log(qiniuhost + ret.info.key)
									}
								}
							});
				},
			},

		})
	}

</script>

</html>
